home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / Resources.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  11.7 KB  |  410 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Resources.h
  3.  
  4.      Contains:    Resource Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __RESOURCES__
  19. #define __RESOURCES__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54. enum {
  55.     resSysHeap                    = 64,                            /*System or application heap?*/
  56.     resPurgeable                = 32,                            /*Purgeable resource?*/
  57.     resLocked                    = 16,                            /*Load it in locked?*/
  58.     resProtected                = 8,                            /*Protected?*/
  59.     resPreload                    = 4,                            /*Load in on OpenResFile?*/
  60.     resChanged                    = 2,                            /*Resource changed?*/
  61.     mapReadOnly                    = 128,                            /*Resource file read-only*/
  62.     mapCompact                    = 64,                            /*Compact resource file*/
  63.     mapChanged                    = 32                            /*Write map out at update*/
  64. };
  65.  
  66.  
  67. enum {
  68.     resSysRefBit                = 7,                            /*reference to system/local reference*/
  69.     resSysHeapBit                = 6,                            /*In system/in application heap*/
  70.     resPurgeableBit                = 5,                            /*Purgeable/not purgeable*/
  71.     resLockedBit                = 4,                            /*Locked/not locked*/
  72.     resProtectedBit                = 3,                            /*Protected/not protected*/
  73.     resPreloadBit                = 2,                            /*Read in at OpenResource?*/
  74.     resChangedBit                = 1,                            /*Existing resource changed since last update*/
  75.     mapReadOnlyBit                = 7,                            /*is this file read-only?*/
  76.     mapCompactBit                = 6,                            /*Is a compact necessary?*/
  77.     mapChangedBit                = 5                                /*Is it necessary to write map?*/
  78. };
  79.  
  80.  
  81. enum {
  82.     kResFileNotOpened            = -1,                            /*ref num return as error when opening a resource file*/
  83.     kSystemResFile                = 0                                /*this is the default ref num to the system file*/
  84. };
  85.  
  86.  
  87. typedef CALLBACK_API( void , ResErrProcPtr )(OSErr thErr);
  88. /*
  89.     WARNING: ResErrProcPtr uses register based parameters under classic 68k
  90.              and cannot be written in a high-level language without 
  91.              the help of mixed mode or assembly glue.
  92. */
  93. typedef REGISTER_UPP_TYPE(ResErrProcPtr)                         ResErrUPP;
  94. enum { uppResErrProcInfo = 0x00001002 };                         /* register no_return_value Func(2_bytes:D0) */
  95. #define NewResErrProc(userRoutine)                                 (ResErrUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  96. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  97.     #pragma parameter CallResErrProc(__A0, __D0)
  98.     void CallResErrProc(ResErrUPP routine, OSErr thErr) = 0x4E90;
  99. #else
  100.     #define CallResErrProc(userRoutine, thErr)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppResErrProcInfo, (thErr))
  101. #endif
  102. EXTERN_API( short )
  103. InitResources                    (void)                                                        ONEWORDINLINE(0xA995);
  104.  
  105. EXTERN_API( void )
  106. RsrcZoneInit                    (void)                                                        ONEWORDINLINE(0xA996);
  107.  
  108. EXTERN_API( void )
  109. CloseResFile                    (short                     refNum)                                ONEWORDINLINE(0xA99A);
  110.  
  111. EXTERN_API( OSErr )
  112. ResError                        (void)                                                        ONEWORDINLINE(0xA9AF);
  113.  
  114. EXTERN_API( short )
  115. CurResFile                        (void)                                                        ONEWORDINLINE(0xA994);
  116.  
  117. EXTERN_API( short )
  118. HomeResFile                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A4);
  119.  
  120. EXTERN_API( void )
  121. CreateResFile                    (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA9B1);
  122.  
  123. EXTERN_API( short )
  124. OpenResFile                        (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA997);
  125.  
  126. EXTERN_API( void )
  127. UseResFile                        (short                     refNum)                                ONEWORDINLINE(0xA998);
  128.  
  129. EXTERN_API( short )
  130. CountTypes                        (void)                                                        ONEWORDINLINE(0xA99E);
  131.  
  132. EXTERN_API( short )
  133. Count1Types                        (void)                                                        ONEWORDINLINE(0xA81C);
  134.  
  135. EXTERN_API( void )
  136. GetIndType                        (ResType *                theType,
  137.                                  short                     index)                                ONEWORDINLINE(0xA99F);
  138.  
  139. EXTERN_API( void )
  140. Get1IndType                        (ResType *                theType,
  141.                                  short                     index)                                ONEWORDINLINE(0xA80F);
  142.  
  143. EXTERN_API( void )
  144. SetResLoad                        (Boolean                 load)                                ONEWORDINLINE(0xA99B);
  145.  
  146. EXTERN_API( short )
  147. CountResources                    (ResType                 theType)                            ONEWORDINLINE(0xA99C);
  148.  
  149. EXTERN_API( short )
  150. Count1Resources                    (ResType                 theType)                            ONEWORDINLINE(0xA80D);
  151.  
  152. EXTERN_API( Handle )
  153. GetIndResource                    (ResType                 theType,
  154.                                  short                     index)                                ONEWORDINLINE(0xA99D);
  155.  
  156. EXTERN_API( Handle )
  157. Get1IndResource                    (ResType                 theType,
  158.                                  short                     index)                                ONEWORDINLINE(0xA80E);
  159.  
  160. EXTERN_API( Handle )
  161. GetResource                        (ResType                 theType,
  162.                                  short                     theID)                                ONEWORDINLINE(0xA9A0);
  163.  
  164. EXTERN_API( Handle )
  165. Get1Resource                    (ResType                 theType,
  166.                                  short                     theID)                                ONEWORDINLINE(0xA81F);
  167.  
  168. EXTERN_API( Handle )
  169. GetNamedResource                (ResType                 theType,
  170.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A1);
  171.  
  172. EXTERN_API( Handle )
  173. Get1NamedResource                (ResType                 theType,
  174.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA820);
  175.  
  176. EXTERN_API( void )
  177. LoadResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A2);
  178.  
  179. EXTERN_API( void )
  180. ReleaseResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A3);
  181.  
  182. EXTERN_API( void )
  183. DetachResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA992);
  184.  
  185. EXTERN_API( short )
  186. UniqueID                        (ResType                 theType)                            ONEWORDINLINE(0xA9C1);
  187.  
  188. EXTERN_API( short )
  189. Unique1ID                        (ResType                 theType)                            ONEWORDINLINE(0xA810);
  190.  
  191. EXTERN_API( short )
  192. GetResAttrs                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A6);
  193.  
  194. EXTERN_API( void )
  195. GetResInfo                        (Handle                 theResource,
  196.                                  short *                theID,
  197.                                  ResType *                theType,
  198.                                  Str255                 name)                                ONEWORDINLINE(0xA9A8);
  199.  
  200. EXTERN_API( void )
  201. SetResInfo                        (Handle                 theResource,
  202.                                  short                     theID,
  203.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A9);
  204.  
  205. EXTERN_API( void )
  206. AddResource                        (Handle                 theData,
  207.                                  ResType                 theType,
  208.                                  short                     theID,
  209.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9AB);
  210.  
  211. EXTERN_API( long )
  212. GetResourceSizeOnDisk            (Handle                 theResource)                        ONEWORDINLINE(0xA9A5);
  213.  
  214. EXTERN_API( long )
  215. GetMaxResourceSize                (Handle                 theResource)                        ONEWORDINLINE(0xA821);
  216.  
  217. EXTERN_API( long )
  218. RsrcMapEntry                    (Handle                 theResource)                        ONEWORDINLINE(0xA9C5);
  219.  
  220. EXTERN_API( void )
  221. SetResAttrs                        (Handle                 theResource,
  222.                                  short                     attrs)                                ONEWORDINLINE(0xA9A7);
  223.  
  224. EXTERN_API( void )
  225. ChangedResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AA);
  226.  
  227. EXTERN_API( void )
  228. RemoveResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AD);
  229.  
  230. EXTERN_API( void )
  231. UpdateResFile                    (short                     refNum)                                ONEWORDINLINE(0xA999);
  232.  
  233. EXTERN_API( void )
  234. WriteResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9B0);
  235.  
  236. EXTERN_API( void )
  237. SetResPurge                        (Boolean                 install)                            ONEWORDINLINE(0xA993);
  238.  
  239. EXTERN_API( short )
  240. GetResFileAttrs                    (short                     refNum)                                ONEWORDINLINE(0xA9F6);
  241.  
  242. EXTERN_API( void )
  243. SetResFileAttrs                    (short                     refNum,
  244.                                  short                     attrs)                                ONEWORDINLINE(0xA9F7);
  245.  
  246. EXTERN_API( short )
  247. OpenRFPerm                        (ConstStr255Param         fileName,
  248.                                  short                     vRefNum,
  249.                                  SInt8                     permission)                            ONEWORDINLINE(0xA9C4);
  250.  
  251. EXTERN_API( Handle )
  252. RGetResource                    (ResType                 theType,
  253.                                  short                     theID)                                ONEWORDINLINE(0xA80C);
  254.  
  255. /*
  256.     Note:     The HOpenResFile trap was not implemented until System 7.  If you want to call HOpenResFile
  257.             while running on System 6 machines, then define USE_HOPENRESFILE_GLUE and link with
  258.             Interface.o which contains glue to implement HOpenResFile on pre-System 7 machines.
  259. */
  260. #ifdef USE_HOPENRESFILE_GLUE
  261. EXTERN_API( short )
  262. HOpenResFile                    (short                     vRefNum,
  263.                                  long                     dirID,
  264.                                  ConstStr255Param         fileName,
  265.                                  SInt8                     permission);
  266.  
  267. #else
  268. EXTERN_API( short )
  269. HOpenResFile                    (short                     vRefNum,
  270.                                  long                     dirID,
  271.                                  ConstStr255Param         fileName,
  272.                                  SInt8                     permission)                            ONEWORDINLINE(0xA81A);
  273.  
  274. #endif  /*  defined(USE_HOPENRESFILE_GLUE)  */
  275.  
  276. /*
  277.     Note:     The HCreateResFile trap was not implemented until System 7.  If you want to call HCreateResFile
  278.             while running on System 6 machines, then define USE_HCREATERESFILE_GLUE and link with
  279.             Interface.o which contains glue to implement HCreateResFile on pre-System 7 machines.
  280. */
  281. #ifdef USE_HCREATERESFILE_GLUE
  282. EXTERN_API( void )
  283. HCreateResFile                    (short                     vRefNum,
  284.                                  long                     dirID,
  285.                                  ConstStr255Param         fileName);
  286.  
  287. #else
  288. EXTERN_API( void )
  289. HCreateResFile                    (short                     vRefNum,
  290.                                  long                     dirID,
  291.                                  ConstStr255Param         fileName)                            ONEWORDINLINE(0xA81B);
  292.  
  293. #endif  /*  defined(USE_HCREATERESFILE_GLUE)  */
  294.  
  295. EXTERN_API( short )
  296. FSpOpenResFile                    (const FSSpec *            spec,
  297.                                  SignedByte             permission)                            TWOWORDINLINE(0x700D, 0xAA52);
  298.  
  299. EXTERN_API( void )
  300. FSpCreateResFile                (const FSSpec *            spec,
  301.                                  OSType                 creator,
  302.                                  OSType                 fileType,
  303.                                  ScriptCode             scriptTag)                            TWOWORDINLINE(0x700E, 0xAA52);
  304.  
  305. EXTERN_API( void )
  306. ReadPartialResource                (Handle                 theResource,
  307.                                  long                     offset,
  308.                                  void *                    buffer,
  309.                                  long                     count)                                TWOWORDINLINE(0x7001, 0xA822);
  310.  
  311. EXTERN_API( void )
  312. WritePartialResource            (Handle                 theResource,
  313.                                  long                     offset,
  314.                                  const void *            buffer,
  315.                                  long                     count)                                TWOWORDINLINE(0x7002, 0xA822);
  316.  
  317. EXTERN_API( void )
  318. SetResourceSize                    (Handle                 theResource,
  319.                                  long                     newSize)                            TWOWORDINLINE(0x7003, 0xA822);
  320.  
  321. EXTERN_API( Handle )
  322. GetNextFOND                        (Handle                 fondHandle)                            TWOWORDINLINE(0x700A, 0xA822);
  323.  
  324. /* Use TempInsertROMMap to force the ROM resource map to be
  325.    inserted into the chain in front of the system. Note that
  326.    this call is only temporary - the modified resource chain
  327.    is only used for the next call to the resource manager.
  328.    See IM IV 19 for more information. 
  329. */
  330. EXTERN_API( void )
  331. TempInsertROMMap                (Boolean                 tempResLoad)                        FIVEWORDINLINE(0x70FF, 0x4A1F, 0x56C0, 0x31C0, 0x0B9E);
  332.  
  333.  
  334. #if CGLUESUPPORTED
  335. EXTERN_API_C( Handle )
  336. getnamedresource                (ResType                 theType,
  337.                                  const char *            name);
  338.  
  339. EXTERN_API_C( Handle )
  340. get1namedresource                (ResType                 theType,
  341.                                  const char *            name);
  342.  
  343. EXTERN_API_C( short )
  344. openrfperm                        (const char *            fileName,
  345.                                  short                     vRefNum,
  346.                                  char                     permission);
  347.  
  348. EXTERN_API_C( short )
  349. openresfile                        (const char *            fileName);
  350.  
  351. EXTERN_API_C( void )
  352. createresfile                    (const char *            fileName);
  353.  
  354. EXTERN_API_C( void )
  355. getresinfo                        (Handle                 theResource,
  356.                                  short *                theID,
  357.                                  ResType *                theType,
  358.                                  char *                    name);
  359.  
  360. EXTERN_API_C( void )
  361. setresinfo                        (Handle                 theResource,
  362.                                  short                     theID,
  363.                                  const char *            name);
  364.  
  365. EXTERN_API_C( void )
  366. addresource                        (Handle                 theResource,
  367.                                  ResType                 theType,
  368.                                  short                     theID,
  369.                                  const char *            name);
  370.  
  371. #endif  /* CGLUESUPPORTED */
  372.  
  373. #if OLDROUTINENAMES
  374. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  375. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  376. #define RmveResource(theResource) RemoveResource(theResource)
  377.  
  378. #endif  /* OLDROUTINENAMES */
  379.  
  380. /*
  381.     These typedefs were originally created for the Copland Resource Mangager
  382. */
  383. typedef short                             ResFileRefNum;
  384. typedef short                             ResID;
  385. typedef short                             ResAttributes;
  386. typedef short                             ResFileAttributes;
  387.  
  388.  
  389.  
  390. #if PRAGMA_STRUCT_ALIGN
  391.     #pragma options align=reset
  392. #elif PRAGMA_STRUCT_PACKPUSH
  393.     #pragma pack(pop)
  394. #elif PRAGMA_STRUCT_PACK
  395.     #pragma pack()
  396. #endif
  397.  
  398. #ifdef PRAGMA_IMPORT_OFF
  399. #pragma import off
  400. #elif PRAGMA_IMPORT
  401. #pragma import reset
  402. #endif
  403.  
  404. #ifdef __cplusplus
  405. }
  406. #endif
  407.  
  408. #endif /* __RESOURCES__ */
  409.  
  410.